package com.zm.zmgz.utils;

import com.zm.zmgz.annotationzm.InformationProhibitedDisplayItem;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class EmployeeUtils {

    public static List<String> getAttributes(Class clazz) { // 传入class,按顺序返回属性名list,会忽略标记EmployeeInformationProhibitedDisplayItem注释的属性
        Field[] fields = clazz.getDeclaredFields();
        List<String> fieldslist = new ArrayList<>();
        for (Field field : fields) {
            if(!field.isAnnotationPresent(InformationProhibitedDisplayItem.class)) { // 如果该属性没有被EmployeeInformationProhibitedDisplayItem注解标注
                String[] splits = field.toGenericString().split("\\."); // 使用反斜杠转义
                fieldslist.add(splits[splits.length-1]);
            }
        }
        return fieldslist;
    }


}
